package main

func maxArea(height []int) int {
	left := 0
	right := len(height) - 1
	res := 0
	for left < right {
		l := right - left
		h := min(height[left], height[right])
		res = min(res, l*h)
		if height[left] <= height[right] {
			left++
		} else {
			right--
		}
	}

	return res
}

func min(x int, y int) int {
	if x < y {
		return x
	}

	return y
}

func max(x int, y int) int {
	if x > y {
		return x
	}

	return y
}

